---
layout: default
---

<div class="container-fluid" style="margin:20px">
  <div class="row">
    <ol class="breadcrumb">
      <li><a href="{{site.baseurl}}/">Home</a></li>
      <li class="active">Search</li>
    </ol>
  </div>
  <div id="search-row" class="row">
    <div id="search">
      <div class="input-group">
        <input id="search-query" class="form-control" type="text"
               autocomplete="off" placeholder="Search ROS">
        <span class="input-group-btn">
          <button id="search-button" title="Search ROS" class="btn btn-default">
            <span class="glyphicon glyphicon-search"></span>
          </button>
          <a href="https://lunrjs.com/guides/searching.html"
             title="Help to Search" class="btn btn-default">
            <span class="glyphicon glyphicon-question-sign"></span>
          </a>
        </span>
      </div>
    </div>
  </div>

  <div class="row" style="margin: 10px 0px 10px 0px;">
    <div class="btn-group btn-group-justified">
      <div class="btn-group">
        <button id="pkgs" type="button" class="search-section-check btn btn-primary active">Packages</button>
      </div>
      <div class="btn-group">
        <button id="deps" type="button" class="search-section-check btn btn-primary">System Dependencies</button>
      </div>
    </div>
  </div>

  <div id="pkgs" class="row container-fluid search-section-tab">
    <div class="row show-if-searching-packages" style="margin: 10px 0px 10px 0px;">
      <p class="progress-label">Searching...</p>
      <div class="progress" style="margin-bottom: 0;">
        <div id="packages-index-loader-bar" class="m-0 progress-bar progress-bar-warning progress-bar-striped active" role="progressbar" style="width: 100%"></div>
      </div>
    </div>
    <div class="row show-if-packages-found" style="display: none;">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">Package search results</h3>
        </div>
        <div id="packages-search-results" class="panel-body table-responsive"></div>
      </div>
    </div>
    <div id="packages-search-pagination" style="display: none;"
         class="row text-center show-if-packages-found">
    </div>
  </div>

  <div id="deps" class="row container-fluid search-section-tab" style="display: none;">
    <div class="row show-if-searching-deps" style="margin: 10px 0px 10px 0px;">
      <p class="progress-label">Searching...</p>
      <div class="progress" style="margin-bottom: 0;">
        <div id="packages-index-loader-bar" class="m-0 progress-bar progress-bar-warning progress-bar-striped active" role="progressbar" style="width: 100%"></div>
      </div>
    </div>
    <div class="row show-if-deps-found" style="display: none;">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">System dependencies search results</h3>
        </div>
        <div id="deps-search-results" class="panel-body table-responsive"></div>
      </div>
    </div>
    <div id="deps-search-pagination" style="display: none;"
         class="row text-center show-if-deps-found">
    </div>
  </div>

</div>

{% raw %}
<script id="packages-search-results-template" type="text/mustache">
  {{#have_entries}}
  <table class="table table-condensed table-striped table-hover">
    <thead>
      <tr>
        <th class="col-xs-1" style="text-align: center;"><span class="glyphicon glyphicon-flash" title="Release status"></span></th>
        <th class="col-xs-1" style="text-align: center;"><span class="glyphicon glyphicon-file" title="README status"></span></th>
        <th class="col-xs-1" style="text-align: center;"><span class="glyphicon glyphicon-time" title="Last commit date"></span></th>
        <th class="col-xs-1">Distro</th>
        <th class="col-xs-2">Name</th>
        <th class="col-xs-4">Repo</th>
      </tr>
    </thead>
    <tbody class="entries">
      {{#entries}}
      <tr>
        {{#released}}
        <td class="text-center col-xs-1">
          <span title="Released" data-toggle="tooltip" data-placement="left" class="glyphicon glyphicon-flash"></span>
        </td>
        {{/released}}
        {{^released}}
        <td title="Not released" data-toggle="tooltip" data-placement="left" class="text-center col-xs-1">
          <span class="glyphicon glyphicon-none"></span>
        </td>
        {{/released}}
        {{#readme}}
        <td title="Has README" data-toggle="tooltip" data-placement="left" align="center" class="col-xs-1">
          <span class="glyphicon glyphicon-file"></span>
        </td>
        {{/readme}}
        {{^readme}}
        <td title="No README" data-toggle="tooltip" data-placement="left" align="center" class="col-xs-1">
          <span class="glyphicon glyphicon-none"></span>
        </td>
        {{/readme}}
        <td class="col-xs-1" align="center"><span class="label label-default">{{last_commit_time}}</span></td>
        <td class="col-xs-1"><span class="label label-default">{{distro}}</span></td>
        <td class="col-xs-2"><a href="{{baseurl}}{{url}}">{{name}}</a></td>
        <td class="col-xs-4"><a href="{{baseurl}}/r/{{repo_name}}/{{instance}}">{{instance}}</a></td>
      </tr>
      {{/entries}}
    </tbody>
  </table>
  {{/have_entries}}
  {{^have_entries}}
  <h4>No related packages found.</h4>
  {{/have_entries}}
</script>
{% endraw %}


{% raw %}
<script id="deps-search-results-template" type="text/mustache">
  {{#have_entries}}
  <table class="table table-condensed table-striped table-hover">
    <thead>
      <tr>
        <th class="col-xs-2">Name</th>
        <th class="col-xs-4">Platforms</th>
        <th class="col-xs-4">Dependants</th>
      </tr>
    </thead>
    <tbody class="entries">
      {{#entries}}
      <tr>
        <td class="col-xs-2"><a href="{{baseurl}}{{url}}">{{name}}</a></td>
        <td class="col-xs-4">
          {{#platforms}}
          <span class="label label-default">{{.}}</span>
          {{/platforms}}
        </td>
        <td class="col-xs-4">
          {{#dependants}}
          <span class="label label-primary pkg-label">{{.}}</span>
          {{/dependants}}
        </td>
      </tr>
      {{/entries}}
    </tbody>
  </table>
  {{/have_entries}}
  {{^have_entries}}
  <h4>No related system dependencies found.</h4>
  {{/have_entries}}
</script>
{% endraw %}

<script src="{{site.baseurl}}/js/lunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/mustache.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/pagination.js" type="text/javascript" charset="utf-8"></script>
<!--<script src="/js/date.format.js" type="text/javascript" charset="utf-8"></script>-->
<script src="{{site.baseurl}}/js/URI.js" type="text/javascript" charset="utf-8"></script>

<script src="{{site.baseurl}}/js/jquery.lunr.db.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/jquery.lunr.views.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/jquery.lunr.search.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/jquery.exec.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
$(function() {

  // Populate the search input with 'q' querystring parameter if set
  var getWindowSearchQuery = function() {
    var uri = new URI(window.location.search.toString());
    return uri.search(true);
  };

  // Populate the search input with 'q' querystring parameter if set
  var setWindowSearchQuery = function(query) {
    var uri = new URI(window.location.toString()); uri.setSearch(query);
    window.history.pushState({path: uri.toString()}, '', uri.toString());
  };

  var copySearchQueryToUI = function() {
    var query = getWindowSearchQuery();
    $('#search-query').val(query.term || '');
    var section = query.section || 'pkgs';
    $('.search-section-tab').hide();
    $('#' + section + '.search-section-tab').show();
    $('.search-section-check').removeClass('active');
    $('#' + section + '.search-section-check').addClass('active');
  };

  var copyUIToSearchQuery = function() {
    setWindowSearchQuery({
      section: $('.search-section-check.active').attr('id'),
      term: $('#search-query').val()
    });
  };

  $('.search-section-check').click(function() {
    if (!$(this).hasClass('active')) {
      var section = $(this).attr('id');
      $('.search-section-check').removeClass('active');
      $('.search-section-tab').fadeOut("fast").promise().then(function() {
        $('#' + section + '.search-section-tab').fadeIn("fast");
      });
      $(this).addClass('active');
    }
    copyUIToSearchQuery();
  });

  $('#search-query').bind('keypress', function(e) {
    if (e.which == 13) {
      copyUIToSearchQuery();
    }
  });

  $('#search-button').click(copyUIToSearchQuery);

  var executor = $.makeExecutor({
    nextTag: function(tags) {
      var section = $('.search-section-check.active').attr('id');
      if (tags.indexOf(section) != -1) return section;
      return tags[Math.floor(Math.random() * tags.length)];
    }, capacity: 2
  });

  copySearchQueryToUI();

  $('#search-query').lunrSearch({
    baseUrl: '{{ site.baseurl }}',
    sections: [{
      partition: {
        shardsUrl: "/search/packages/shards.json",
        getData: function(url) {
          return executor.push(function() {
            return $.getJSON(url);
          }, 'pkgs');
        },
        ready: function() {
          $('.show-if-searching-packages').slideUp(400);
        }
      },
      view: $('#packages-search-pagination').pagedView({
        pageView: $('#packages-search-results').templateView({
          template: $('#packages-search-results-template').text()
        }),
        doShow: function(duration) {
          $('.show-if-packages-found').slideDown(duration);
          return $('.show-if-packages-found').promise();
        },
        doHide: function(duration) {
          $('.show-if-packages-found').slideUp(duration);
          return $('.show-if-packages-found').promise();
        }
      })
    }, {
      partition: {
        shardsUrl: "/search/deps/shards.json",
        getData: function(url) {
          return executor.push(function() {
            return $.getJSON(url);
          }, 'deps');
        },
        ready: function() {
          $('.show-if-searching-deps').slideUp(400);
        }
      },
      view: $('#deps-search-pagination').pagedView({
        pageView: $('#deps-search-results').templateView({
          template: $('#deps-search-results-template').text(),
          doPreprocess: function(raw_entries, context) {
            return $.map(raw_entries, function(raw_entry) {
              return $.extend({}, raw_entry, {
                platforms: raw_entry['platforms'].split(' : '),
                dependants: raw_entry['dependants'].split(' : '),
              });
            });
          }
        }),
        doShow: function(duration) {
          $('.show-if-deps-found').slideDown(duration);
          return $('.show-if-deps-found').promise();
        },
        doHide: function(duration) {
          $('.show-if-deps-found').slideUp(duration);
          return $('.show-if-deps-found').promise();
        }
      })
    }]
  });

  $(window).bind('popstate', function() {
    copySearchQueryToUI();

    $('#search-query').trigger('search');
  });

});
</script>
